import collections
class Solution(object):
    def numKLenSubstrNoRepeats(self, s, k):
        """
        :type s: str
        :type k: int
        :rtype: int
        """
        n = len(s)
        if k > 26 or k > n:
            return 0
        out = 0
        d = collections.defaultdict(int)
        for i in range(k):
            d[s[i]] += 1
        if len(d) == k:
            out += 1
        for i in range(n - k):
            d[s[i + k]] += 1
            d[s[i]] -= 1
            if d[s[i]] == 0:
                d.pop(s[i])
            if len(d) == k:
                out += 1
        return out


data = Solution()
S = "havefunonleetcode"
K = 5
print(data.numKLenSubstrNoRepeats(S, K))
